package xin.marcher.module.replenished.remote;

import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Component;
import xin.marcher.module.common.core.JsonResult;
import xin.marcher.module.common.core.PageResult;
import xin.marcher.module.replenished.exception.ReplenishedBizException;
import xin.marcher.module.seller.api.SellerAbilityApi;
import xin.marcher.module.seller.domain.request.SellerGroupRequest;
import xin.marcher.module.seller.domain.response.SellerGroupResponse;

/**
 * 卖家能力API
 *
 *
 */
@Component
public class SellerRemote {

    @DubboReference(version = "1.0.0")
    private SellerAbilityApi sellerAbilityApi;


    /**
     * 分页查询卖家组
     *
     * @param pageNo
     * @param pageSize
     * @return
     */
    public PageResult<SellerGroupResponse> getSellerGroupList(Integer pageNo, Integer pageSize, Integer sellerGroupType) {
        SellerGroupRequest sellerGroupRequest = new SellerGroupRequest();
        sellerGroupRequest.setPageNo(pageNo);
        sellerGroupRequest.setPageSize(pageSize);
        sellerGroupRequest.setSellerGroupType(sellerGroupType);

        sellerGroupRequest.setNeedSellerInfo(true);
        JsonResult<PageResult<SellerGroupResponse>> jsonResult = sellerAbilityApi.getSellerGroupList(sellerGroupRequest);
        if (!jsonResult.getSuccess()) {
            throw new ReplenishedBizException(jsonResult.getErrorCode(), jsonResult.getErrorMessage());
        }
        return jsonResult.getData();
    }
}
